package NWish.properties.custom
{
	import NWish.Logger;
	import NWish.json.Json;
	import NWish.json.OrderDict;
	import NWish.properties.Properties;
	
	import away3d.containers.Scene3D;
	
	public class CustomProperties// extends Properties
	{
		public function CustomProperties()
		{
			//super(parent);
		}
		
		//
		public function toString()
		{
			return 'CustomProperties';
		}
		public function get type()
		{
		}
		public function get createEnable()
		{
			return false;
		}
		public function get multiCreateEnable()
		{
			return false;
		}
		
		public function getJSON(obj = null,scene = null):String
		{
			if(obj == null
				|| obj.extra == null
				|| obj.extra.customProperties == null)
				return '';
			
			var s:String = Json.encode( obj.extra.customProperties );
			
			return s;
		}
		
		public function apply(obj, properties:String, scene:Scene3D)
		{
			var dict:Object = Json.decode( properties,false );
			
			if(obj.extra == null)
				obj.extra = new Object();
			
			obj.extra.customProperties = dict;
		}
		
		public function save(obj,toDict:OrderDict)
		{
			if(obj.extra && obj.extra.customProperties)
			{
				toDict.push(toString(),obj.extra.customProperties);
			
				return obj.extra.customProperties;
			}
		}
		
		public function load(dict,obj,scene)
		{
			var cp = dict[toString()];
			if(cp)
			{
				if(obj.extra == null)
					obj.extra = new Object();
				
				obj.extra.customProperties = cp;
			}
		}
	}
	

}








